﻿@Html.DevExpress().GridView(
    settings => {
        settings.Name = "grid";
        settings.CallbackRouteValues = new { Controller = "Accessibility", Action = "KeyboardSupportPartial" };
        settings.Width = Unit.Percentage(100);
        
        settings.KeyboardSupport = true;
        settings.AccessKey = "G";
        
        settings.KeyFieldName = "ProductID";
        settings.CommandColumn.VisibleIndex = 0;
        settings.CommandColumn.ShowSelectCheckbox = true;
        settings.Columns.Add("ProductID");
        settings.Columns.Add("ProductName");
        settings.Columns.Add(
            column => {
                column.FieldName = "CategoryID";
                column.Caption = "Category";
                column.GroupIndex = 0;

                column.ColumnType = MVCxGridViewColumnType.ComboBox;
                var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                comboBoxProperties.DataSource = NorthwindDataProvider.GetCategories();
                comboBoxProperties.TextField = "CategoryName";
                comboBoxProperties.ValueField = "CategoryID";
                comboBoxProperties.ValueType = typeof(int);
            }
        );
        settings.Columns.Add("UnitPrice").PropertiesEdit.DisplayFormatString = "{0:C}";

        settings.Settings.ShowGroupPanel = true;
        settings.SettingsBehavior.AutoExpandAllGroups = true;
        settings.SettingsBehavior.AllowSelectByRowClick = true;
    }
).Bind(Model).GetHtml()